typedef double Scalar;

typedef struct {
    Scalar history[M];
} ScalarHistory;

void shInit(ScalarHistory*vh){
    int j;
    for (j=0; j<M; ++j){
        vh->history[j] = 0;
    }
}

void shPush(ScalarHistory*vh, Scalar s){
    memmove(vh->history+1, vh->history, (M-1)*sizeof(Scalar));
    vh->history[0] = s;
}

void shPrint(ScalarHistory*vh){
    int j;
    printf("sh\n");
    printf("[");
    for (j=0; j<M; ++j){
        printf("%12g ", vh->history[j]);
    }
    printf("]\n");
}
